/**
 * 全局样式文件
 */
@import './variables.scss';
@import './mixins.scss';

// 重置样式
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  padding: 0;
  font-family: $font-family-base;
  font-size: $font-size-base;
  line-height: $line-height-base;
  color: $text-color;
  background-color: $background-color;
  overflow-x: hidden;
  
  // iOS 滚动优化
  -webkit-overflow-scrolling: touch;
  
  // 禁用双击缩放
  touch-action: manipulation;
}

// 输入框样式重置
input, textarea, select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  
  &:focus {
    outline: none;
  }
  
  &::placeholder {
    color: $text-color-placeholder;
    opacity: 1;
  }
}

// 按钮样式重置
button {
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
  
  &:focus {
    outline: none;
  }
  
  &:disabled {
    cursor: not-allowed;
    opacity: 0.6;
  }
}

// 链接样式重置
a {
  color: inherit;
  text-decoration: none;
  
  &:hover, &:active, &:focus {
    text-decoration: none;
    outline: none;
  }
}

// 图片样式
img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
  border: 0;
}

// 列表样式重置
ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

// 标题样式重置
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: normal;
}

// 段落样式重置
p {
  margin: 0;
}

// 表格样式重置
table {
  border-collapse: collapse;
  border-spacing: 0;
}

// 滚动条样式
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 2px;
  
  &:hover {
    background: rgba(0, 0, 0, 0.3);
  }
}

// 选择文本样式
::selection {
  background: $primary-color;
  color: #fff;
}

::-moz-selection {
  background: $primary-color;
  color: #fff;
}

// 页面容器
.page {
  min-height: 100vh;
  background-color: $background-color;
  
  &.page-with-tabbar {
    padding-bottom: 50px;
  }
  
  &.page-with-navbar {
    padding-top: 46px;
  }
}

// 内容容器
.container {
  max-width: $container-max-width;
  margin: 0 auto;
  padding: 0 $spacing-md;
}

// 卡片样式
.card {
  background: #fff;
  border-radius: $border-radius-md;
  box-shadow: $box-shadow-light;
  overflow: hidden;
  
  &.card-padding {
    padding: $spacing-md;
  }
  
  &.card-margin {
    margin: $spacing-md;
  }
}

// 分割线
.divider {
  height: 1px;
  background: $border-color;
  margin: $spacing-md 0;
  
  &.divider-thick {
    height: 8px;
    background: $background-color-light;
  }
}

// 空状态
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: $spacing-xl;
  color: $text-color-secondary;
  
  .empty-icon {
    font-size: 48px;
    margin-bottom: $spacing-md;
    opacity: 0.5;
  }
  
  .empty-text {
    font-size: $font-size-md;
    line-height: 1.5;
    text-align: center;
  }
}

// 加载状态
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: $spacing-lg;
  color: $text-color-secondary;
  
  .loading-icon {
    margin-right: $spacing-xs;
  }
}

// 错误状态
.error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: $spacing-xl;
  color: $error-color;
  
  .error-icon {
    font-size: 48px;
    margin-bottom: $spacing-md;
  }
  
  .error-text {
    font-size: $font-size-md;
    line-height: 1.5;
    text-align: center;
    margin-bottom: $spacing-md;
  }
  
  .error-button {
    padding: $spacing-sm $spacing-md;
    background: $primary-color;
    color: #fff;
    border-radius: $border-radius-sm;
    font-size: $font-size-sm;
  }
}

// 工具类
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-justify { text-align: justify; }

.text-primary { color: $primary-color; }
.text-success { color: $success-color; }
.text-warning { color: $warning-color; }
.text-error { color: $error-color; }
.text-info { color: $info-color; }
.text-secondary { color: $text-color-secondary; }
.text-placeholder { color: $text-color-placeholder; }
.text-disabled { color: $text-color-disabled; }

.text-xs { font-size: $font-size-xs; }
.text-sm { font-size: $font-size-sm; }
.text-md { font-size: $font-size-md; }
.text-lg { font-size: $font-size-lg; }
.text-xl { font-size: $font-size-xl; }

.font-normal { font-weight: normal; }
.font-medium { font-weight: 500; }
.font-bold { font-weight: bold; }

.text-ellipsis {
  @include text-ellipsis;
}

.text-ellipsis-2 {
  @include text-ellipsis(2);
}

.text-ellipsis-3 {
  @include text-ellipsis(3);
}

.clearfix {
  @include clearfix;
}

// 布局类
.flex {
  display: flex;
}

.flex-column {
  display: flex;
  flex-direction: column;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-around {
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.flex-start {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.flex-end {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.flex-wrap {
  flex-wrap: wrap;
}

.flex-nowrap {
  flex-wrap: nowrap;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.flex-3 { flex: 3; }
.flex-4 { flex: 4; }
.flex-5 { flex: 5; }

.align-start { align-items: flex-start; }
.align-center { align-items: center; }
.align-end { align-items: flex-end; }
.align-stretch { align-items: stretch; }

.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }

// 间距类
.m-0 { margin: 0; }
.m-1 { margin: $spacing-xs; }
.m-2 { margin: $spacing-sm; }
.m-3 { margin: $spacing-md; }
.m-4 { margin: $spacing-lg; }
.m-5 { margin: $spacing-xl; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: $spacing-xs; }
.mt-2 { margin-top: $spacing-sm; }
.mt-3 { margin-top: $spacing-md; }
.mt-4 { margin-top: $spacing-lg; }
.mt-5 { margin-top: $spacing-xl; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: $spacing-xs; }
.mb-2 { margin-bottom: $spacing-sm; }
.mb-3 { margin-bottom: $spacing-md; }
.mb-4 { margin-bottom: $spacing-lg; }
.mb-5 { margin-bottom: $spacing-xl; }

.ml-0 { margin-left: 0; }
.ml-1 { margin-left: $spacing-xs; }
.ml-2 { margin-left: $spacing-sm; }
.ml-3 { margin-left: $spacing-md; }
.ml-4 { margin-left: $spacing-lg; }
.ml-5 { margin-left: $spacing-xl; }

.mr-0 { margin-right: 0; }
.mr-1 { margin-right: $spacing-xs; }
.mr-2 { margin-right: $spacing-sm; }
.mr-3 { margin-right: $spacing-md; }
.mr-4 { margin-right: $spacing-lg; }
.mr-5 { margin-right: $spacing-xl; }

.p-0 { padding: 0; }
.p-1 { padding: $spacing-xs; }
.p-2 { padding: $spacing-sm; }
.p-3 { padding: $spacing-md; }
.p-4 { padding: $spacing-lg; }
.p-5 { padding: $spacing-xl; }

.pt-0 { padding-top: 0; }
.pt-1 { padding-top: $spacing-xs; }
.pt-2 { padding-top: $spacing-sm; }
.pt-3 { padding-top: $spacing-md; }
.pt-4 { padding-top: $spacing-lg; }
.pt-5 { padding-top: $spacing-xl; }

.pb-0 { padding-bottom: 0; }
.pb-1 { padding-bottom: $spacing-xs; }
.pb-2 { padding-bottom: $spacing-sm; }
.pb-3 { padding-bottom: $spacing-md; }
.pb-4 { padding-bottom: $spacing-lg; }
.pb-5 { padding-bottom: $spacing-xl; }

.pl-0 { padding-left: 0; }
.pl-1 { padding-left: $spacing-xs; }
.pl-2 { padding-left: $spacing-sm; }
.pl-3 { padding-left: $spacing-md; }
.pl-4 { padding-left: $spacing-lg; }
.pl-5 { padding-left: $spacing-xl; }

.pr-0 { padding-right: 0; }
.pr-1 { padding-right: $spacing-xs; }
.pr-2 { padding-right: $spacing-sm; }
.pr-3 { padding-right: $spacing-md; }
.pr-4 { padding-right: $spacing-lg; }
.pr-5 { padding-right: $spacing-xl; }

// 显示隐藏类
.show { display: block !important; }
.hide { display: none !important; }
.invisible { visibility: hidden; }
.visible { visibility: visible; }

// 位置类
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

// 浮动类
.float-left { float: left; }
.float-right { float: right; }
.float-none { float: none; }

// 溢出类
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-scroll { overflow: scroll; }
.overflow-visible { overflow: visible; }

// 宽高类
.w-100 { width: 100%; }
.h-100 { height: 100%; }
.w-auto { width: auto; }
.h-auto { height: auto; }

// 圆角类
.rounded { border-radius: $border-radius-md; }
.rounded-sm { border-radius: $border-radius-sm; }
.rounded-lg { border-radius: $border-radius-lg; }
.rounded-full { border-radius: 50%; }
.rounded-none { border-radius: 0; }

// 边框类
.border { border: 1px solid $border-color; }
.border-top { border-top: 1px solid $border-color; }
.border-bottom { border-bottom: 1px solid $border-color; }
.border-left { border-left: 1px solid $border-color; }
.border-right { border-right: 1px solid $border-color; }
.border-none { border: none; }

// 阴影类
.shadow { box-shadow: $box-shadow-light; }
.shadow-md { box-shadow: $box-shadow-base; }
.shadow-lg { box-shadow: $box-shadow-dark; }
.shadow-none { box-shadow: none; }

// 背景类
.bg-white { background-color: #fff; }
.bg-gray { background-color: $background-color-light; }
.bg-primary { background-color: $primary-color; }
.bg-success { background-color: $success-color; }
.bg-warning { background-color: $warning-color; }
.bg-error { background-color: $error-color; }
.bg-info { background-color: $info-color; }
.bg-transparent { background-color: transparent; }

// 深色模式适配
@media (prefers-color-scheme: dark) {
  .auto-dark {
    color: $text-color-dark;
    background-color: $background-color-dark;
    
    .card {
      background: $background-color-dark-light;
      color: $text-color-dark;
    }
    
    .divider {
      background: $border-color-dark;
    }
    
    ::-webkit-scrollbar-thumb {
      background: rgba(255, 255, 255, 0.2);
      
      &:hover {
        background: rgba(255, 255, 255, 0.3);
      }
    }
  }
}

// 响应式断点
@include respond-below(sm) {
  .container {
    padding: 0 $spacing-sm;
  }
  
  .card {
    &.card-margin {
      margin: $spacing-sm;
    }
  }
}

@include respond-above(lg) {
  .container {
    padding: 0 $spacing-lg;
  }
}

// 动画类
.fade-enter-active,
.fade-leave-active {
  transition: opacity $transition-duration ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

.slide-up-enter-active,
.slide-up-leave-active {
  transition: transform $transition-duration ease;
}

.slide-up-enter-from,
.slide-up-leave-to {
  transform: translateY(100%);
}

.slide-down-enter-active,
.slide-down-leave-active {
  transition: transform $transition-duration ease;
}

.slide-down-enter-from,
.slide-down-leave-to {
  transform: translateY(-100%);
}

.slide-left-enter-active,
.slide-left-leave-active {
  transition: transform $transition-duration ease;
}

.slide-left-enter-from,
.slide-left-leave-to {
  transform: translateX(100%);
}

.slide-right-enter-active,
.slide-right-leave-active {
  transition: transform $transition-duration ease;
}

.slide-right-enter-from,
.slide-right-leave-to {
  transform: translateX(-100%);
}

.zoom-enter-active,
.zoom-leave-active {
  transition: transform $transition-duration ease;
}

.zoom-enter-from,
.zoom-leave-to {
  transform: scale(0);
}